package com.grgbanking.it.system.service.impl;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.grgbanking.it.common.json.JSONHelper;
import com.grgbanking.it.system.dao.IEquipmentDao;
import com.grgbanking.it.system.dao.IUserDao;
import com.grgbanking.it.system.entity.GrgemEquipments;
import com.grgbanking.it.system.entity.User;
import com.grgbanking.it.system.service.IOaService;



/**
 * OA相关
 * 
 * OaService
 * 
 * @author 潘广伟
 * @Email p_3er@qq.com
 * @Date 2014-11-18 上午8:57:10
 * 
 * @version 1.0.0
 *
 */
@Service
public class OaService implements IOaService {
	@Autowired
	private IUserDao<User, Integer> userDao;
	@Autowired
	private IEquipmentDao<GrgemEquipments, String> equipmentDao;

	public String findGrgemEquipmentsByUser(String username) throws Exception {
		StringBuffer sql = new StringBuffer("select t.EQUI_ID,t.DETAIL from grgem_equipments_01 t where t.deleted=0 ");
		sql.append(" and t.use_user='").append(username).append("'");
		System.out.println(sql);
		List<Map> list = userDao.listBySQL(sql.toString());
		return JSONHelper.convertToGrid(userDao.getTotalBySQL(sql.toString()), list);
	}

	@Override
	public GrgemEquipments getEquipmentById(String id) throws Exception {
		
		return equipmentDao.findById(id);
	}
}